package com.ftg.learn.rbac.incrementer;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.ftg.learn.util.IdGenerator;
import com.ftg.learn.util.IdWorker;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @author Guo
 * @date 2022/2/9
 */
@Component
public class CustomIdGenerator implements IdentifierGenerator {

    @Override
    public Long nextId(Object entity) {
        // 填充自己的Id生成器， incrementerCustomIdGenerator
        return IdGenerator.generateId();
        //可以将当前传入的class全类名来作为bizKey,或者提取参数来生成bizKey进行分布式Id调用生成.

//        String bizKey = entity.getClass().getName();
//        IdWorker worker = new IdWorker(1,bizKey.hashCode(),1);
//        return worker.nextId();
    }


}
